/*
 * @Date: 2023-07-07 10:52:58
 * @LastEditors: lyx
 * @LastEditTime: 2023-07-07 14:08:31
 * @FilePath: \sup-mimi-program-server\src\main.ts
 * @Description:
 */
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { AppModule } from './app.module';
import { join } from 'path';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { ValidationPipe } from '@nestjs/common';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  // 静态资源
  app.useStaticAssets(join(__dirname, '..', 'public'), { prefix: '/static' });
  // 管道验证
  app.useGlobalPipes(new ValidationPipe());
  // Swagger 文档
  const config = new DocumentBuilder()
    .setTitle('Supcon-5T-小程序API')
    .setDescription('基于nestJS, 为 5T 内部小程序提供 API支持')
    .setVersion('1.0')
    .addTag('mini-program')
    .build();
  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('api-docs', app, document);

  await app.listen(3000);
  console.log('项目地址: http://localhost:3000');
  console.log('项目Swagger地址: http://localhost:3000/api-docs');
}
bootstrap();
